package com.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.entity.Permissions;
import com.entity.UserRole;
import com.mapper.RoleMapper;
import com.service.UserRoleService;

@Transactional
@Service
public class UserRoleServiceImpl implements UserRoleService {
	@Autowired
	RoleMapper roleMapper;
	public List<UserRole> selectAll() {
		// TODO Auto-generated method stub
		return roleMapper.selectAll();
	}

	public List<Permissions> selectPermissionsByRoleId(Long id) {
		// TODO Auto-generated method stub
		return roleMapper.selectRolePermissions(id);
	}

	public int addRolePermission(Long roleId, Long[] permIds) {
		// TODO Auto-generated method stub
		roleMapper.deletePermissByRoleId(roleId);
		return roleMapper.addRolePermiss(roleId, permIds);
	}

	public List<Permissions> selectRolePermissions(Long id) {
		// TODO Auto-generated method stub
		return roleMapper.selectRolePermissions(id);
	}

}
